package com.gemantic.glue.handler;



import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;

import com.gemantic.glue.context.GlueExecHelper;
import com.gemantic.glue.model.ReturnT;

public abstract class BizGlueHandler extends IGlueHandler {

    @Override
    public void init() throws Exception {
        System.out.println("BizGlueHandler init");
        super.init();
    }

    @Override
    public void execute() throws Exception {
        ConcurrentMap<String, Object> pack = GlueExecHelper.getPack();
        ReturnT<String> stringReturnT = doExecute(pack);
        ConcurrentHashMap<String, Object> handleResult = new ConcurrentHashMap<>();
        handleResult.put("resData",stringReturnT.getContent());
        GlueExecHelper.handleResult(stringReturnT.getCode(),stringReturnT.getMsg(), handleResult);
    }

    public abstract ReturnT<String> doExecute(ConcurrentMap<String, Object> pack) throws Exception;

    @Override
    public void destroy() throws Exception {
        System.out.println("BizGlueHandler destroy");
        super.destroy();
    }
}
